import isEmpty from 'lodash/isEmpty';

// 获取手机号码正则
export function getPhoneReg() {
    return /^1[3456789]\d{9}$/;
}

//是否为空
export function isCheckEmpty(data) {
    return isEmpty(data);
}

//
export function isHad(key, keys) {
    if (!key && key !== 0) return false;
    if (!keys || !Array.isArray(keys)) return false;
    if (!isNaN(key)) return keys.includes(Number(key));
    return keys.includes(key);
}

// 手机号码脱敏
export function getHideMiddlePhone(e) {
    if (checkPhone(e)) {
        e = e.replace(/^(1[3-9][0-9])\d{4}(\d{4}$)/, '$1****$2');
    }
    return e;
}

// 身份证脱敏
export function getHideMiddleCard(e) {
    if (checkCardId(e)) {
        e = e.replace(/^(.{6})(?:\d+)(.{4})$/, '$1****$2');
    }
    return e;
}
